package com.example.httpdemo.net;

import com.example.httpdemo.model.MessageModel;
import com.example.httpdemo.model.RefreshTokenModel;
import com.example.httpdemo.model.RefreshTokenRequestModel;
import com.example.httpdemo.model.SmsRequest;
import com.example.httpdemo.model.User;

import java.util.List;

import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.core.Single;

import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.Path;
import retrofit2.http.Query;

public interface ApiService {

    @POST("sms/code")
    @Headers("No-Authentication: true")
    Single<MessageModel> getSms(@Body SmsRequest request);

    @POST("sms/code")
    Single<MessageModel> getSms1(@Body SmsRequest request);

    @POST("refresh_token")
    @Headers("No-Authentication: true") // 标记此请求不需要认证
    Call<RefreshTokenModel> refreshToken(@Body RefreshTokenRequestModel request);

    // 获取用户信息
    @GET("users/{username}")
    Single<User> getUser(@Path("username") String username);

    // 搜索用户
    @GET("users/search")
    Single<List<User>> searchUsers(@Query("query") String query);

    // 创建用户
    @POST("users")
    Single<User> createUser(@Body User user);


}